﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MethodWorx.CMS.Content;
using MethodWorx.CMS.UI.Models.Shared;
using MethodWorx.CMS.Services;

namespace MethodWorx.CMS.UI.Models
{
    public class CreateRootPageTemplateModel
    {
        private SchemaService service;
        public PageTemplateBasicDetails PageTemplateBasicDetails { get; set; }
        public PageTemplate ChildPageTemplate { get; set; }

        public CreateRootPageTemplateModel(SchemaService service, Guid? id)
            : this(service, id, new PageTemplateBasicDetails())
        {
        }

        public CreateRootPageTemplateModel(SchemaService service, Guid? id, PageTemplateBasicDetails details)
        {
            this.service = service;
            this.PageTemplateBasicDetails = details;
            this.PageTemplateBasicDetails.ParentsSelectList =
                new SelectList(service.GetAbstractPageTemplates(), "Id", "Name");

            if(id.HasValue)
                this.ChildPageTemplate = service.GetPageTemplateById(id.Value);
        }      

    }
}
